﻿/**
 * 定义XMLHttpRequest
 */
var request;
//创建XMLHttpRequest对象函数
function getRequestObject(){
	if(window.ActiveXObject){
		request = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		request = new XMLHttpRequest();
	}else{
		window.alert("你的浏览器不支持XMLHttpRequest,无法使用AJAX功能！");
	}
}
//回调方法
function loginResult(){
	if((request.readyState == 4) && (request.status == 200)){	
		document.getElementById("div_1").innerHTML = request.responseText;
	
	}
}
//发送请求，绑定回调方法
var num = 1;
var answersum="";

bn = document.getElementById("button_1");
bn.onclick = function(){
	var ss=bn.value;
	if(ss=="下一题"){	
		var sel ="";
		var select=document.getElementsByName("selcet");
	
		 for(var i=0;i<select.length;i++){
	         if(select[i].checked){
	         sel = sel + select[i].value+"."
	         }
		 } 
		
		 answersum = answersum + sel +",";
//		if(document.getElementById("answera").checked==true){		
//			answera = document.getElementById("answera").value;	
//			answersum = answersum + answera+",";
//		}else if(document.getElementById("answerb").checked==true){
//			answerb = document.getElementById("answerb").value;
//			answersum = answersum+answerb+",";
//		}else if(document.getElementById("answerc").checked==true){
//			answerc = document.getElementById("answerc").value;
//			answersum = answersum+answerc+",";
//		}else if(document.getElementById("answerd").checked==true){
//			answerd = document.getElementById("answerd").value;
//			answersum = answersum+answerd+",";
//		}else if(document.getElementById("answere").checked==true){
//			answere = document.getElementById("answere").value;
//			answersum = answersum+answere+",";
//		}else{
//			answerf = document.getElementById("answerf").value;
//			answersum = answersum+answerf+",";
//		}
	}
	bn.value='下一题';
//	document.getElementById("div_0").innerHTML="<br/>" +
//			"<input type='radio' name='selcet' id='answera' value='0' /><br/>" +
//			"<input type='radio' name='selcet' id='answerb' value='1' />";

	//创建XMLHttpRequest对象
	getRequestObject();
	//绑定回调方法
	request.onreadystatechange = loginResult;
	//发送请求
	request.open("GET","QuestionAction?num="+num+"&flag=go&answerc="+answersum,true);
	num++;
	//发送Post请求
//	request.open("POST", "Question", true);
//	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded,charset=UTF-8");
	request.send(null);
}


